package com.candy.candysocket.business.service;

import com.candy.candysocket.business.service.impl.CGLibRetryProxyHandler;
import com.candy.candysocket.business.service.impl.MsgServiceImpl;
import com.candy.candysocket.business.service.impl.MsgServiceImpl2;
import com.candy.candysocket.business.service.impl.RetryInvocationHandler;

/**
 * @author suYanLong
 * @version 1.0
 * @date 2023/8/18 13:45
 * @Description 描述
 */
public class Test {

    /**
     * 重试机制方案；从参考：https://mp.weixin.qq.com/s/YU6fS_bDyJE8Q-aiuUvxtA
     * 1、for循环硬编码重试
     * 2、静态代理重试
     * 3、JDK动态代理重试
     * 4、CGLib动态代理重试
     * 5、AOP封装重试
     * 6、spring-retry重试
     * 7、guava-retry重试
     * 8、mq异步重试
     *
     * @param args
     */
    public static void main(String[] args) {
        MsgService msgService = new MsgServiceImpl();
        MsgService proxy = (MsgService) RetryInvocationHandler.getProxy(msgService);
        proxy.getName();

        MsgServiceImpl2 msgServiceImpl2 = new MsgServiceImpl2();
        CGLibRetryProxyHandler cgLibRetryProxyHandler = new CGLibRetryProxyHandler();
        MsgServiceImpl2 msgServiceImpl21 = (MsgServiceImpl2) cgLibRetryProxyHandler.getCglibProxy(msgServiceImpl2);
        msgServiceImpl21.getName();
    }

}
